﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EPiServer.Templates.BPP
{
	public partial class Post : EPiServer.SimplePage
	{
		protected override void OnPreRender(EventArgs e)
		{
			SetupControls();
			base.OnPreRender(e);
		}

		private void SetupControls()
		{
			NameLiteral.Text = CurrentPage.PageName;
			ContentLiteral.Text = CurrentPage.Property["Content"].ToString();
			CommentRepeater.DataSource = EPiServer.DataFactory.Instance.GetChildren(CurrentPage.PageLink);
			CommentRepeater.DataBind();
		}

		protected void CommentRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
		{
			EPiServer.Core.PageData pageData = (EPiServer.Core.PageData)e.Item.DataItem;
			if (pageData != null)
			{
				((Literal)e.Item.FindControl("CommentLiteral")).Text = pageData.Property["Content"].ToString();
			}
		}
	}
}
